diff options
Diffstat (limited to 'app/api/partners/rfq-last/[id]/response/route.ts')
| -rw-r--r-- | app/api/partners/rfq-last/[id]/response/route.ts | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/app/api/partners/rfq-last/[id]/response/route.ts b/app/api/partners/rfq-last/[id]/response/route.ts index db320dde..1fc9d5dd 100644 --- a/app/api/partners/rfq-last/[id]/response/route.ts +++ b/app/api/partners/rfq-last/[id]/response/route.ts @@ -156,7 +156,10 @@ export async function POST( const fileRecords = [] if (files.length > 0) { - for (const file of files) { + for (let i = 0; i < files.length; i++) { + const file = files[i] + const metadata = data.fileMetadata?.[i] // 인덱스로 메타데이터 매칭 + try { const filename = `${uuidv4()}_${file.name.replace(/[^a-zA-Z0-9.-]/g, '_')}` const filepath = path.join(uploadDir, filename) @@ -165,28 +168,25 @@ export async function POST( if (file.size > 50 * 1024 * 1024) { // 50MB 이상 await saveFileStream(file, filepath) } else { - // 작은 파일은 기존 방식 const buffer = Buffer.from(await file.arrayBuffer()) await writeFile(filepath, buffer) } fileRecords.push({ vendorResponseId: result.id, - attachmentType: (file as any).attachmentType || "기타", + attachmentType: metadata?.attachmentType || "기타", // 메타데이터에서 가져옴 fileName: filename, originalFileName: file.name, filePath: `/uploads/rfq/${rfqId}/${filename}`, fileSize: file.size, fileType: file.type, - description: (file as any).description, + description: metadata?.description || "", // 메타데이터에서 가져옴 uploadedBy: session.user.id, }) } catch (fileError) { console.error(`Failed to save file ${file.name}:`, fileError) - // 파일 저장 실패 시 계속 진행 (다른 파일들은 저장) } } - // DB에 파일 정보 저장 if (fileRecords.length > 0) { await db.insert(rfqLastVendorAttachments).values(fileRecords) |
